#include<stdio.h>
#include<stdlib.h>

int n ;


void display(int** arr2){
	int i,j;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++)
			printf("%d \t",arr2[i][j]);		
	printf("\n");
	}
}

int** transpose(int **arr1){
	int i,j;
	for(i=0;i<n;i++){
		for(j=0;j<i;j++){
			int temp = arr1[i][j];	
			arr1[i][j] = arr1[j][i];
			arr1[j][i] = temp;
		
		}
	}
	printf("\n");
//	display(arr1);
//	printf("\n%d\n", arr1[1][0]);
	return arr1;
}

int** invertTo90Degree(int** arr){
	int i,j;
	for(i=0;i<n;i++){
		for(j=n-1;j>=i;j--){
			int temp = arr[j][i];	
			arr[j][i] = arr[n-1-j][i];
			arr[n-1-j][i] = temp;
		
		}
	}
	printf("\n");
//	display(arr);
	return arr;

}

int main(){
	int i , j;
	printf("Enter the size of N*N matrix ie, N = ");
	scanf("%d",&n);
	int **a=(int **)malloc(n*sizeof(int *));
      	for(i=0;i<n;i++)
		a[i]=(int *)malloc(n*sizeof(int));
	for(i=0;i<n;i++){
		printf("\nEnter the %d row values \n",i);
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	int **a1=(int **)malloc(n*sizeof(int *));
      	for(i=0;i<n;i++)
		a1[i]=(int *)malloc(n*sizeof(int));

	int **a2=(int **)malloc(n*sizeof(int *));
      	for(i=0;i<n;i++)
		a2[i]=(int *)malloc(n*sizeof(int));

	display(a);
	a1=transpose(a);
	display(a);
	printf("\n");
	a2=invertTo90Degree(a);
	display(a2);
	printf("\n");

return 1;
}
